import { createRouter, createWebHashHistory } from 'vue-router';

const routes = [
  {
    path: '/test',
    component: () => import('@/views/layout/index.vue'),
    meta: {
      title: 'layout'
    },
    children: [
      {
        path: 'bar',
        name: '柱状图',
        component: () => import('@/views/echarts/bar-page.vue'),
      },
      {
        path: 'pie',
        name: '饼图',
        component: () => import('@/views/echarts/pie-page.vue'),
      },
      {
        path: 'parent',
        name: 'parent',
        component: () => import('@/views/keepAlive/parent.vue'),
        meta: {
          title: '父组件',
          keepAlive: true
        }
      },
      {
        path: 'children',
        name: 'children',
        component: () => import('@/views/keepAlive/children.vue'),
        meta: {
          title: '子组件',
        }
      },
      {
        path: 'pinia',
        name: 'pinna',
        component: () => import('@/views/vue3Api/pinia.vue'),
      },
      {
        path: 'shopping-cart',
        name: 'shopping-cart',
        component: () => import('@/views/shoppingCart/index.vue')
      }
    ]
  },
  {
    path: '/404',
    component: () => import('@/views/error/404/index.vue'),
    meta: {
      title: '404'
    }
  },
  
  {
    path: '/upload',
    name: '上传图片',
    component: () => import('@/views/form/upload.vue'),
  },
  {
    path: '/form',
    name: '上传表单',
    component: () => import('@/views/form/form.vue'),
  },
  {
    path: '/lines',
    name: '飞线图',
    component: () => import('@/views/echarts/lines.vue'),
  },
  {
    path: '/vue3',
    name: 'vue3',
    component: () => import('@/views/vue3Api/index.vue'),
  },
  {
    path: '/components',
    name: 'tab组件',
    component: () => import('@/views/vue3Api/components.vue'),
  },
  {
    path: '/parentForm',
    name: '动态表单组件',
    component: () => import('@/views/parentForm/index.vue'),
  },
  {
    path: '/sedpcacpn',
    name: '联系人',
    component: () => import('@/views/sedpcacpn/index.vue'),
  }
];

const router = createRouter({
  history: createWebHashHistory(),
  routes
});

// const whiteList = ['/404', '/vue3', '/bar', '/pie', '/']

// router.beforeEach((to, from) => {
//   console.log('to=====>', to.path, from.path);
//   if(whiteList.includes(to.path)) {
//     return true;
//   }else {
//     return '/404'
//   }
// })



export default router;